#ifndef _VLA_H_
#define _VLA_H_

#ifdef __cplusplus
extern "C"	{
#endif

//pre alloced defined here
#define VLA_SIZE_DEF    64	

#define VLA_SIZEOF(p)	((p)->size)	
#define VLA_FOR_EACH(p, v)	for((p) = (v)->buf; (void *)(p) != (v)->buf+(v)->isize*(v)->size; (p)=(void *)(p) + (v)->isize)

typedef struct vla{
	unsigned int isize;	//size of element
	void * buf;			//linear buf
	unsigned int size;	//number of elements in vla
	unsigned int volume;//max number of elements vla can saved 
} vla;

vla * vla_new(int isize);
void * vla_set(vla * p, int i);
void * vla_get(vla * p, int i);
int vla_clear(vla * p);
int vla_free(vla * p);


#ifdef __cplusplus
}
#endif

#endif
